/**
 * file:   Test.java
 * date:   2014.07.12
 * author: weiwei
 * desc:   TODO
 */
package designPattern.Proxy;

import java.lang.reflect.Proxy;

/**
 * @author weiwei
 * 
 */
public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		UserDao userDao = new UserDaoImpl();
		DebugInterceptor di = new DebugInterceptor();
		di.setTarget(userDao);
		// Proxy.newProxyInstance(loader, interfaces,
		// h)参数分别表示调用函数的类加载器,调用函数的全部接口,实现此代理的类
		UserDao userDaoProxy = (UserDao) Proxy.newProxyInstance(userDao
				.getClass().getClassLoader(), userDao.getClass()
				.getInterfaces(), di);
		System.out.println(userDaoProxy.getClass().getName());
		System.out.println(userDaoProxy.getClass().getMethods());
		userDaoProxy.save(new User());

	}

}
